package com.group.www.service.impl;

import com.group.www.dao.impl.CategoryInfoDao;
import com.group.www.dao.impl.GoodsInfoDao;
import com.group.www.interfaces.CategoryInfoServiceI;
import com.group.www.interfaces.ICategoryInfo_q;
import com.group.www.pojo.CategoryInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@com.alibaba.dubbo.config.annotation.Service
@Service
public class CategoryInfoServiceImp implements CategoryInfoServiceI,ICategoryInfo_q{
    @Autowired
    private CategoryInfoDao dao;
    @Autowired
    private GoodsInfoDao goodsdao;
    @Override
    public boolean add(CategoryInfo entity) {
        return dao.add(entity);
    }

    @Override
    public boolean update(CategoryInfo entity) {
        return dao.update(entity);
    }

    @Override
    public List<CategoryInfo> query() {
        return dao.query();
    }

    @Override
    public boolean delete(CategoryInfo entity) {
        String id=entity.getCategoryid().toString();
        /***先删除对应的商品*/
        goodsdao.delete(-1+"",id+"");
        return dao.delete(id);
    }

    @Override
    public boolean deleteMany(String ids) {
        /***先删除对应的商品*/
        goodsdao.delete(-1+"",ids+"");
        return dao.delete(ids);
    }

    @Override
    public CategoryInfo queryById(int id) {
        return dao.queryById(id);
    }

    @Override
    public List<CategoryInfo> queryAllCategoryInfo() {
        return dao.queryAllCategoryInfo();
    }
}
